package net.zjitc.dao.impl;

import net.zjitc.dao.BookDao;
import net.zjitc.domain.Book;
import net.zjitc.utils.C3p0Utils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;


import java.sql.SQLException;
import java.util.List;

/**
 * Created by rj1502 on 2017/10/16.
 */
public class BookDaoImpl implements BookDao {
    @Override
    public List<Book> findAll() throws SQLException {
        QueryRunner runner = new QueryRunner(C3p0Utils.getDateSource());
        String sql = "select * from product";
        List<Book> list = (List<Book>) runner.query(sql,new BeanListHandler(Book.class));
        return list;
    }
}
